# -*- coding:utf-8 -*-
import time
import datetime
import random

# 随机等待间隔
class RandWait:
    def __init__(self, min, max) -> None:
        self.rand_time = (min, max)
        self.last_time = None

    def wait(self):
        while True:
            now = datetime.datetime.now()
            wait_second = random.randint(self.rand_time[0], self.rand_time[1])
            if not self.last_time is None and (now-self.last_time).seconds < wait_second:
                time.sleep(10)
            else:
                self.last_time = now
                break